function do_ajax(type,base_url,controller,sid) { 
   var ajax = new Ajax(); 
    ajax.responseType = type; 
	switch (type) { 
	  case Ajax.JSON: 
	    ajax.ondone = function(data) { 
		  document.getElementById('ajax1').setTextValue(data.message + ' The current time is: ' + data.time + '. '); 
		  document.getElementById('ajax2').setInnerFBML(data.fbml_test); } 
		  break; 
		case Ajax.FBML: 
		  ajax.ondone = function(data) { 
		   document.getElementById('render_layout_' + sid).setInnerFBML(data); 
		   document.getElementById('render_layout_' + sid).setStyle('display','on'); 
		   document.getElementById('indicator_' + sid).setStyle('display','none'); 
                  } 
                  break; 
		case Ajax.RAW: 
		  ajax.ondone = function(data) { 
		    document.getElementById('ajax1').setTextValue(data); 
			document.getElementById('ajax2').setTextValue(''); } 
			break; 
		 } 
			
       ajax.requireLogin = true;
       ajax.post('http://' + base_url + '/' + controller + '?sid=' + sid ); 
		  
} 

function showDialog(url, title, ok, cancel) {                                          
    // Set the default pop-up dialog values for those not supplied.                    
    if (title === undefined) { title = "Dialog"; }                                     
    if (ok === undefined) { ok = "Okay"; }                                             
    if (cancel === undefined) { cancel = "Cancel"; }                                   
                                                                                       
    // Build the AJAX object to request the dialog contents.                           
    var ajax = new Ajax();                                                             
    ajax.responseType = Ajax.FBML;                                                     
    ajax.requireLogin = true;                                                          
    ajax.ondone = function(data) {                                                     
        // Fill the Dialog's DIV element with the FBML returned by the AJAX request.   
        // This will overwrite the loading message FBML currently nested in the DIV.   
        document.getElementById('dialog_content').setInnerFBML(data);                  
    };                                                                                 
                                                                                       
    // Create a "loading" dialog box that will be updated via the AJAX request.        
    dialog = new Dialog().showChoice(title, dialog_fbml, ok, cancel);                  
    dialog.onconfirm = function() {                                                    
        // Submit the Dialog's form if it exists, then hide the dialog.                
        frm = document.getElementById('dialog_form');                                  
        if (frm) { frm.submit(); }                                                     
        dialog.hide();                                                                 
    };                                                                                 
    // Update the dialog contents via Mock AJAX request.                               
    ajax.post('http://' + url);                                                                    
}                                                                                      



function toggle_expend(sid){
     
}
function dismiss_ajax(type,id) {
   var ajax = new Ajax();
    ajax.responseType = Ajax.FBML;
    ajax.ondone = function(data) {
      //document.getElementById('comments_layout_' + sid).setInnerFBML(data);
    }
    ajax.requireLogin = true;
    ajax.post('http://9a860085.fb.joyent.us/users/hide_' + type + '?id='+id);

}
